import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from "vuex-persistedstate"
//使用vuex插件
Vue.use(Vuex)
export default new Vuex.Store({
  //全局状态
  state: {
    //用户身份令牌
    token: '',
    //当前登录用户名
    loginUserName: '',
    //激活的菜单
    menuIndex: '',
    //一级菜单
    breadcrumbTitle: '',
    //二级菜单
    breadcrumbIndex: '',
    //头像地址
    headImgUrl:'',
    //权限列表
    authIndexList:'',
    //当前订单编号
    currentOrderId:'',
    //当前订单信息
    currentOrder:'',
    //司机备证图片
    baseDriverPhoto:[],
    //订单操作类型
    orderOperationType:'addOrder',
    //调度单
    dispatchTicket:'',
    //路线跟踪类型
    trackOverviewType:'nodeOverview',

    carDetail:'',
    carBasePhotos:'',
    //调度单操作类型空代表新增 edit代表编辑detail代表详情
    dispatchOption:'',
    //当前调度单
    currentDispatchTicket:{},

    carInfoToDistributeTask:'',
    //跳转order详情所待的order信息
    msgToJumpOrder:'',

    //最短路径对象
    shortPathCity:[],
    //车辆详情页跳转到调度单详情带的车辆信息
    carInfoToDispatchEdit:''

  },
  //同步数据提交
  mutations: {
    carInfoToDispatchEdit(state, param) {
      state.carInfoToDispatchEdit = param
    },
    baseDriverPhoto(state, param) {
      state.baseDriverPhoto = param
    },
    msgToJumpOrder(state, param) {
      state.msgToJumpOrder = param
    },
    carInfoToDistributeTask(state, param) {
      state.carInfoToDistributeTask = param
    },
    carBasePhotos(state, param) {
      state.carBasePhotos = param
    },
    carDetail(state, param) {
      state.carDetail = param
    },
    token(state, param) {
      state.token = param
    },
    loginUserName(state, param) {
      state.loginUserName = param
    },
    menuIndex(state, param) {
      state.menuIndex = param
    },
    breadcrumbTitle(state, param) {
      state.breadcrumbTitle = param
    },
    breadcrumbIndex(state, param) {
      state.breadcrumbIndex = param
    },
    headImgUrl(state, param) {
      state.headImgUrl = param
    }
    ,
    authIndexList(state, param) {
      state.authIndexList = param
    },
    currentOrderId(state, param) {
      state.currentOrderId = param
    },
    currentOrder(state, param) {
      state.currentOrder = param
    },
    orderOperationType(state, param) {
      state.orderOperationType = param
    },
    dispatchOption(state, param) {
      state.dispatchOption = param
    },
    currentDispatchTicket(state, param) {
      state.currentDispatchTicket = param
    },
    dispatchTicket(state, param) {
      state.dispatchTicket = param
    },
    trackOverviewType(state, param) {
      state.trackOverviewType = param
    }
  },
  //引入持久化组件
  plugins: [createPersistedState()]
})
